package mycine.model.beans;

import java.io.Serializable;
import javax.persistence.*;

/**
 *
 * @author Vincent
 */
@Entity
@Table(name = "episode")
@NamedQueries({
	@NamedQuery(name = "Episode.findAll", query = "SELECT e FROM Episode e"),
	@NamedQuery(name = "Episode.findById", query = "SELECT e FROM Episode e WHERE e.id = :id"),
	@NamedQuery(name = "Episode.findByTitle", query = "SELECT e FROM Episode e WHERE e.title = :title"),
	@NamedQuery(name = "Episode.findByNumber", query = "SELECT e FROM Episode e WHERE e.number = :number")})
public class Episode implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
	private Integer id;
	@Basic(optional = false)
    @Column(name = "title")
	private String title;
	@Basic(optional = false)
    @Column(name = "number")
	private int number;
	@JoinColumn(name = "series", referencedColumnName = "id")
    @ManyToOne(optional = false)
	private Series series;

	public Episode() {
	}

	public Episode(Integer id) {
		this.id = id;
	}

	public Episode(Integer id, String title, int number) {
		this.id = id;
		this.title = title;
		this.number = number;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}

	public Series getSeries() {
		return series;
	}

	public void setSeries(Series series) {
		this.series = series;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Episode)) {
			return false;
		}
		Episode other = (Episode) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "mycine.model.beans.Episode[ id=" + id + " ]";
	}
	
}
